package com.feicheng.controller.admin;


import com.alibaba.fastjson.JSONObject;
import com.feicheng.common.result.ResultInfo;
import com.feicheng.service.a.FFjService;
import com.feicheng.service.a.FMjService;
import com.feicheng.service.a.FYyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/room")

public class FjController {

    @Autowired
    FFjService fjService;
    @Autowired
    FYyService yyService;
    @Autowired
    FMjService mjService;

    @GetMapping("/page")
    public ResultInfo getByPage(
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "12") Integer size,
            String searchKey
    ) {

        JSONObject param = new JSONObject();
        param.put("current", current);
        param.put("size", size);
        param.put("rname", searchKey);
        param.put("mj", searchKey);
        param.put("rnrs", searchKey);
        param.put("yjds", searchKey);

        param = fjService.getRoomsByPage(param);
        return ResultInfo.success(param.get("arooms"));
    }

    @GetMapping("/info")
    public ResultInfo getRoomInfo(@RequestParam("roomid") String roomid){
        JSONObject param = new JSONObject();
        param.put("roomid", roomid);
        param = fjService.getRoom(param);

        return  ResultInfo.success(param);

    }

    @PostMapping("/import")
    public ResultInfo importFj(@RequestBody JSONObject param) {
        return ResultInfo.success(fjService.importFj(param));
    }


}
